<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="formOperacoesNegociais" >

        <p:panel header="OPERAÇÕES NEGOCIAIS" >

            <br/>

            <p:commandButton icon="ui-icon-plus"   
                             value="Novo" 
                             actionListener="#{operacaoNegocialBean.prepareCreate}" 
                             update=":formOperacaoNegocial"
                             oncomplete="dialogOperacaoNegocial.show()"
                             />

            <br/><br/>

            <p:dataTable id="dtOperacoesNegociais"
                         var="item" 
                         value="#{operacaoNegocialBean.items}" 
                         emptyMessage="Não há operações negociais cadastradas" 
                         rowKey="#{item.id}" 
                         paginator="true" 
                         rows="10"  
                         rowsPerPageTemplate="5,10,15,20,25,30,35,40,45,50">

                <p:column headerText="Tipo Operação Negocial" > 

                    <h:outputText value="#{item.tipoOperacaoNegocial.descricao}" />

                </p:column>  

                <p:column headerText="Cliente" > 

                    <h:outputText value="#{item.cliente.nome}" />

                </p:column> 

                <p:column headerText="Valor Total" > 

                    <h:outputText value="#{item.valorTotal}" >

                        <f:convertNumber currencySymbol="R$"
                                         type="currency"
                                         locale="pt"/>

                    </h:outputText>

                </p:column> 

                <p:column headerText="Comissão" > 

                    <h:outputText value="#{item.valorComissao}" >

                        <f:convertNumber currencySymbol="R$"
                                         type="currency"
                                         locale="pt"/>

                    </h:outputText>

                </p:column> 

                <p:column headerText="Opções" 
                          style="width: 80px; text-align: center "> 

                    <p:commandButton icon="ui-icon-pencil"   
                                     title="editar operacaoNegocial" 
                                     update=":formOperacaoNegocial"
                                     oncomplete="dialogOperacaoNegocial.show()" > 

                        <f:setPropertyActionListener target="#{operacaoNegocialBean.selected}"
                                                     value="#{item}" />

                    </p:commandButton>

                    <p:commandButton icon="ui-icon-close"   
                                     title="excluir operacaoNegocial" 
                                     update=":formExclusaoOperacaoNegocial"
                                     oncomplete="exclusaoOperacaoNegocial.show()"> 

                        <f:setPropertyActionListener target="#{operacaoNegocialBean.selected}"
                                                     value="#{item}" />

                    </p:commandButton>

                </p:column>

                <f:facet name="footer" >  

                    <div style="float: right">

                        Valor Total Comissão:

                        <h:outputText value="#{operacaoNegocialBean.valorTotalComissao}" >

                            <f:convertNumber currencySymbol="R$"
                                             type="currency"
                                             locale="pt"/>

                        </h:outputText>

                    </div>

                    <br/>

                </f:facet>

            </p:dataTable>

        </p:panel>

    </h:form>

</ui:composition>

